package vip.xiaonuo.facedoor.rule;

import cn.hutool.extra.spring.SpringUtil;
import com.deliveredtechnologies.rulebook.RuleState;
import com.deliveredtechnologies.rulebook.annotation.*;
import lombok.extern.slf4j.Slf4j;
import vip.xiaonuo.facedoor.iservice.*;


/**
 * 协议规则引擎
 */
@Rule
@Slf4j
public class DwRulesEngine {

    @Given("manufacturer")
    private ManufacturerEnums manufacturer;

    public static IFaceDoorDtoService faceDoorDtoService;

    public static IDeviceBaseService deviceBaseService;
    public static IDeviceSetService deviceSetService;
    public static IMemberDealWithService memberDealWithService;

    public static IMemberDeviceService memberDeviceService;
    public static IVisitorDealWithService visitorDealWithService;

    public static IVisitorDeviceService visitorDeviceService;

    public static IAppVersionService appVersionService;

    @When
    public boolean when() {
        return ManufacturerEnums.DW.equals(this.manufacturer);
    }

    @Then
    public RuleState then() {
        log.info("德沃规则引擎启动加载类");
        faceDoorDtoService = SpringUtil.getBean(RuleConstant.DW + RuleConstant.FACEDOOR_DTO);
        deviceBaseService = SpringUtil.getBean(RuleConstant.DW + RuleConstant.DEVICE_BASE);
        deviceSetService = SpringUtil.getBean(RuleConstant.DW + RuleConstant.DEVICE_SET);
        memberDealWithService = SpringUtil.getBean(RuleConstant.DW + RuleConstant.MEMBER_DEAL_WITH);
        memberDeviceService = SpringUtil.getBean(RuleConstant.DW + RuleConstant.MEMBER_DEVICESE);
        visitorDealWithService = SpringUtil.getBean(RuleConstant.DW + RuleConstant.VISITOR_DEAL_WITH);
        visitorDeviceService = SpringUtil.getBean(RuleConstant.DW + RuleConstant.VISITOR_DEVICE);
//        appVersionService = SpringUtil.getBean(RuleConstant.DW + RuleConstant.APP_UPDATE);
        return RuleState.NEXT;
    }

}
